<style>
    .layui-form-item label {
        width: 120px;
    }
    .classifyimg{
        margin-bottom: 20px;
        width: 672px !important;
    }
    .classifyimg-item{
        display: inline-block;
        width: 140px;
    }
    .classifyimg img{
        width: 100px;
        display: block;
    }
    .classifyimg .layui-form-radio{
        vertical-align: top;
        display: block;
        margin-bottom: 10px;
    }
    .image_storage_type .item{
        display: none;
    }
</style>
<div class="layui-card" style="padding:10px;">
    {:shopToken()}
    <div class="layui-tab" lay-filter="setting">
        <ul class="layui-tab-title">
            <li lay-id="platform" class="layui-this">平台设置</li>
            <li lay-id="users">会员设置</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form class="layui-form seller-alone-form" action="" method="post">
                    <div class="layui-form-item">
                        <label class="layui-form-label">{$data['shop_name']['name']}：</label>
                        <div class="layui-input-inline seller-inline-5">
                            <input type="text" name="shop_name" value="{$data['shop_name']['value']}" lay-verify="title" autocomplete="off" placeholder="请输入平台名称" class="layui-input">
                        </div>
                        <div class="layui-form-mid layui-word-aux">平台名称会显示到前台，请合理输入此名称</div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{$data['shop_desc']['name']}：</label>
                        <div class="layui-input-inline seller-inline-5" style="margin-bottom: 10px">
                            <textarea name="shop_desc" class="layui-textarea">{$data['shop_desc']['value']}</textarea>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{$data['shop_beian']['name']}：</label>
                        <div class="layui-input-inline seller-inline-5">
                            <input type="text" name="shop_beian" value="{$data['shop_beian']['value']}" lay-verify="title" autocomplete="off" placeholder="请输入ICP备案号" class="layui-input">
                        </div>
                        <div class="layui-form-mid layui-word-aux">如：苏ICP备88888888号-1</div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{$data['about_article_id']['name']}：</label>
                        <div class="layui-input-inline seller-inline-5" style="margin-bottom: 10px">
                            <input type="text" id="about_article" name="about_article" readonly="readonly" value="{$data['about_article']['value']}" required placeholder="请选择广告文章" autocomplete="off" class="layui-input" onclick="article_list('article_id', 'about_article')">
                            <input type="hidden" id="article_id" name="about_article_id" value="{$data['about_article_id']['value']}">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{$data['user_agreement_id']['name']}：</label>
                        <div class="layui-input-inline seller-inline-5" style="margin-bottom: 10px">
                            <input type="text" id="user_agreement" name="user_agreement" readonly="readonly" value="{$data['user_agreement']['value']}" required placeholder="请选择广告文章" autocomplete="off" class="layui-input" onclick="article_list('user_agreement_id', 'user_agreement')">
                            <input type="hidden" id="user_agreement_id" name="user_agreement_id" value="{$data['user_agreement_id']['value']}">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{$data['privacy_policy_id']['name']}：</label>
                        <div class="layui-input-inline seller-inline-5" style="margin-bottom: 10px">
                            <input type="text" id="privacy_policy" name="privacy_policy" readonly="readonly" value="{$data['privacy_policy']['value']}" required placeholder="请选择广告文章" autocomplete="off" class="layui-input" onclick="article_list('privacy_policy_id', 'privacy_policy')">
                            <input type="hidden" id="privacy_policy_id" name="privacy_policy_id" value="{$data['privacy_policy_id']['value']}">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{$data['shop_logo']['name']}：</label>
                        <div class="layui-input-inline seller-inline-6">
                            {shop:image id='shop_logo' value="$data['shop_logo']['value']" name="shop_logo"/}
                        </div>
                        <div class="layui-form-mid layui-word-aux"></div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">&nbsp;</label>
                        <div class="layui-input-block">
                            <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="save" style="height: 37px;padding: 0 27px;font-size: 14px;">保存</button>
                        </div>
                    </div>
                </form>
            </div>

            <div class="layui-tab-item">
                <form class="layui-form seller-alone-form" action="" method="post">
                    <div class="layui-form-item">
                        <label class="layui-form-label">{$data['is_bind_mobile']['name']}：</label>
                        <div class="layui-input-inline seller-inline-4">
                            <input type="radio" lay-filter="is_bind_mobile" name="is_bind_mobile" value="1" title="绑定" {eq name="$data['is_bind_mobile']['value']" value="1" }checked{/eq}>
                            <input type="radio" lay-filter="is_bind_mobile" name="is_bind_mobile" value="2" title="不绑定" {eq name="$data['is_bind_mobile']['value']" value="2" }checked{/eq}>
                        </div>
                        <div class="layui-form-mid layui-word-aux">第三方登录的时候是否需要绑定手机号码，强烈建议绑定手机号码。</div>
                    </div>
                    <div class="layui-form-item" style="margin-top: 20px;">
                        <label class="layui-form-label">{$data['shop_mobile']['name']}：</label>
                        <div class="layui-input-inline seller-inline-5">
                            <input type="text" name="shop_mobile" value="{$data['shop_mobile']['value']}" lay-verify="title" autocomplete="off" placeholder="请输入接收通知手机号" class="layui-input">
                        </div>
                        <div class="layui-form-mid layui-word-aux">前台下单时给商家发送短信通知</div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">&nbsp;</label>
                        <div class="layui-input-block">
                            <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="save" style="height: 37px;padding: 0 27px;font-size: 14px;">保存</button>
                        </div>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>

<script>
    layui.use(['form', 'element', 'table'], function() {
        var form = layui.form, element = layui.element, table = layui.table;

        //显示当前tab
        if (location.hash) {
            element.tabChange('setting', location.hash.replace(/^#/, ''));
        }
        element.on('tab(setting)', function () {
            var othis = $(this), layid = othis.attr('lay-id');
            if (layid) {
                location.hash = layid;
            }
        });

        //保存商品
        form.on('submit(save)', function(data) {
            formData = data.field;
            if (!formData) {
                layer.msg('请先完善数据', {
                    time: 1300
                }); //layer.msg(JSON.stringify(data.field));
                return false;
            }
            JsPost('{:url("Setting/index")}',formData,function(e){
                if (e.status === true) {
                    layer.msg('保存成功');
                } else {
                    layer.msg(e.msg, {
                        time: 1300
                    });
                }
            });
            return false;
        });

        //积分奖励类型切换
        var type = $("#sign_point_type").val();
        if (type == 1) {
            $(".sign-random").hide();
            $(".sign-fixed").show();
        } else {
            $(".sign-random").show();
            $(".sign-fixed").hide();
        }
        form.on('radio(sign_point_type)', function(data) {
            if (data.value == 1) {
                $(".sign-random").hide();
                $(".sign-fixed").show();
            } else {
                $(".sign-random").show();
                $(".sign-fixed").hide();
            }
        });
        //存储引擎切换
        form.on('select(image_storage_type)', function(data) {
            $(".image_storage_type .item").hide(10);
            $("."+data.value).show(10);
        });

        //监听文章列表页工具条
        table.on('tool(articleTable)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象
            if(layEvent === 'selectArticle'){ //选择
                var article_id_key = $("#article_id_key").val();
                var article_name_key = $("#article_name_key").val();
                $("#"+article_id_key).val(data.id);
                $("#"+article_name_key).val(data.title);
                layer.close(window.box);
            }
        });
    });

    function article_list(id, name)
    {
        JsGet("{:url('Carousel/getArticle')}?article_id_key="+id+"&article_name_key="+name,function(e){
            window.box = layer.open({
                type: 1,
                content: e,
                area: ['700px', '450px'],
                title:'文章列表'
            });
        });
    }
</script>